<template>
	<view>
		<u-grid :col="3">
			<u-grid-item>
				<u-icon name="photo" :size="46"></u-icon>
				<view class="grid-text">图片</view>
			</u-grid-item>
			<u-grid-item>
				<u-icon name="lock" :size="46"></u-icon>
				<view class="grid-text">锁头</view>
			</u-grid-item>
			<u-grid-item>
				<u-icon name="hourglass" :size="46"></u-icon>
				<view class="grid-text">沙漏</view>
			</u-grid-item>
			<u-grid-item class="bg-green-500">
				<image src="../../static/扫描.png" mode="aspectFit" class="w-50 h-50"></image>
				<view class="grid-text" @click="scan">获取</view>
			</u-grid-item>
			<u-grid-item class="bg-green-500">
				<image src="../../static/tabbar/优惠劵.png" mode="aspectFit" class="w-50 h-50"></image>
				<view class="grid-text" @click="open">转赠</view>
			</u-grid-item>
		</u-grid>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				vouchers: [],
				url:''
			}
		},
		async created() {
			this.vouchers = await this.api.get('voucher')
		},
		methods: {
			open() {
				uni.navigateTo({
					url: './receive'
				})
			},
			scan() {
				let That=this
				uni.scanCode({
					scanType: ['barCode'],
					success: function(res) {
						// console.log('条码类型：' + res.scanType);
						// console.log('条码内容：' + res.result);
						That.url = res.result
						That.sendQr()
					}
				});
			},
			async sendQr(){
				await this.api.post(this.url)
				uni.redirectTo({
					url:"./receive"
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.grid-text {
		font-size: 28rpx;
		margin-top: 4rpx;
		color: $u-type-info;
	}

	.slot-content {
		font-size: 28rpx;
		color: $u-content-color;
		padding-left: 30rpx;
	}
</style>
